package com.infolab.aims.common.exception;

import org.hibernate.NonUniqueObjectException;


public class DataStoreException extends RuntimeException {
	
	private Throwable ex;
	
	private String columnName;
	private boolean uniqueConstraint = false;
	private boolean identifierConstraint = false;
	
	public DataStoreException(boolean uniqueConstraint,String columnName) {
		this.uniqueConstraint=true;
		this.columnName=columnName;
	}
	
	public DataStoreException(Throwable ex) {
		this.ex=ex;
		if(ex instanceof NonUniqueObjectException)
			identifierConstraint=true;
		
	}

	public String getMessage() {
		if(uniqueConstraint) return "Unique Constraint Exception";
		return ex.getMessage();
	}

	public boolean isUniqueConstraint() {
		return uniqueConstraint;
	}

	public boolean isIdentifierConstraint() {
		return identifierConstraint;
	}

	public String getColumnName() {
		return columnName;
	}
	
	
	
}
